package co.edu.usbcali.sgi.modelo.dto;

import co.edu.usbcali.sgi.modelo.Marca;
import co.edu.usbcali.sgi.presentation.backEndBeans.MarcaView;

import java.io.Serializable;

import java.util.Date;

import javax.faces.event.ActionEvent;


/**
*
*
* @author Zathura Code Generator http://code.google.com/p/zathura
*
*/
public class MarcaDTO implements Serializable {
    private static final long serialVersionUID = 1L;
    private String marNombre;
    private String tpvCod_TipoVehiculo;
    private String marCod;
    private boolean rowSelected = false;
    private MarcaView marcaView;
    private Marca marca;

    public Marca getMarca() {
        return marca;
    }

    public String listener_update(ActionEvent e) {
        try {
            marcaView.action_modifyWitDTO(((marCod == null) ||
                marCod.equals("")) ? null : new String(marCod),
                ((marNombre == null) || marNombre.equals("")) ? null
                                                              : new String(
                    marNombre),
                ((tpvCod_TipoVehiculo == null) ||
                tpvCod_TipoVehiculo.equals("")) ? null
                                                : new String(
                    tpvCod_TipoVehiculo));
            rowSelected = !rowSelected;
        } catch (Exception ex) {
            return "";
        }

        return "";
    }

    public void listener_cancel(ActionEvent e) {
        marCod = marca.getMarCod().toString();
        marNombre = (marca.getMarNombre() != null)
            ? marca.getMarNombre().toString() : null;
        tpvCod_TipoVehiculo = (marca.getTipoVehiculo().getTpvCod() != null)
            ? marca.getTipoVehiculo().getTpvCod().toString() : null;
        rowSelected = !rowSelected;
    }

    /**
    * <p>Bound to commandLink actionListener in the ui that renders/unrenders
        * the Customer details for editing.</p>
        */
    public void toggleSelected(ActionEvent e) {
        marCod = marca.getMarCod().toString();
        marNombre = (marca.getMarNombre() != null)
            ? marca.getMarNombre().toString() : null;
        tpvCod_TipoVehiculo = (marca.getTipoVehiculo().getTpvCod() != null)
            ? marca.getTipoVehiculo().getTpvCod().toString() : null;
        rowSelected = !rowSelected;
    }

    public void setMarca(Marca marca) {
        this.marca = marca;
    }

    public MarcaView getMarcaView() {
        return marcaView;
    }

    public void setMarcaView(MarcaView marcaView) {
        this.marcaView = marcaView;
    }

    public String getMarNombre() {
        return marNombre;
    }

    public void setMarNombre(String marNombre) {
        this.marNombre = marNombre;
    }

    public String getTpvCod_TipoVehiculo() {
        return tpvCod_TipoVehiculo;
    }

    public void setTpvCod_TipoVehiculo(String tpvCod_TipoVehiculo) {
        this.tpvCod_TipoVehiculo = tpvCod_TipoVehiculo;
    }

    public String getMarCod() {
        return marCod;
    }

    public void setMarCod(String marCod) {
        this.marCod = marCod;
    }

    public boolean isRowSelected() {
        return rowSelected;
    }

    public void setRowSelected(boolean rowSelected) {
        this.rowSelected = rowSelected;
    }
}
